<?php
    include_once("../inc/login_controll.inc.php");
	include_once("../class/config.class.php"); 
	$config = config::getConfig();
	include_once($config->getValue("home_path")."/inc/defines.inc.php");

	include_once(HOME_PATH."/class/form.class.php");
	include_once(HOME_PATH."/class/database.class.php");
		
	$oForm = new form($config);
	$oDB = new database($config);
	$oForm->setDB($oDB);
	
	if(isset($_POST['save']) && $_POST['save']=="true"){
		$oForm->addQuestion($_POST['question'], $_POST['f']);
		header("location:new_quest.php?form=".(int)$_POST['f']);
	}
	
	if(isset($_GET['form']) && $_GET['form']!=""){
		$iFormId = (int)$_GET['form'];
		if($oForm->userIsOwnerOfForm($_SESSION['user_id'],$iFormId)){
			$aQuestions = $oForm->getQuestionsByFormNorm($iFormId);
			include(HOME_PATH."/templates/header.tpl.php");
			include(HOME_PATH."/templates/admin/new_quest.tpl.php");
			include(HOME_PATH."/templates/footer.tpl.php");
		}else{
			header("location:teacher.php");
		}
	}
?>